// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.commands.serverCommands;

import java.util.ArrayList;
import zombie.commands.CommandBase;
import zombie.commands.CommandHelp;
import zombie.commands.CommandName;
import zombie.commands.RequiredRight;
import zombie.core.raknet.UdpConnection;
import zombie.network.GameServer;

@CommandName(
    name = "players"
)
@CommandHelp(
    helpText = "UI_ServerOptionDesc_Players"
)
@RequiredRight(
    requiredRights = 62
)
public class PlayersCommand extends CommandBase {
    public PlayersCommand(String username, String userAccessLevel, String command, UdpConnection connection) {
        super(username, userAccessLevel, command, connection);
    }

    @Override
    protected String Command() {
        ArrayList arrayList = new ArrayList();

        for (int int0 = 0; int0 < GameServer.udpEngine.connections.size(); int0++) {
            UdpConnection udpConnection = (UdpConnection)GameServer.udpEngine.connections.get(int0);

            for (int int1 = 0; int1 < 4; int1++) {
                if (udpConnection.usernames[int1] != null) {
                    arrayList.add(udpConnection.usernames[int1]);
                }
            }
        }

        StringBuilder stringBuilder = new StringBuilder("Players connected (" + arrayList.size() + "): ");
        String string0 = " <LINE> ";
        if (this.connection == null) {
            string0 = "\n";
        }

        stringBuilder.append(string0);

        for (String string1 : arrayList) {
            stringBuilder.append("-").append(string1).append(string0);
        }

        return stringBuilder.toString();
    }
}
